function output = hypdiscountMLE(params)

k = params(1);
p = params(2);
alpha = 1; % risk neutral
% p = 1;

global input predicted

N = size(input,1);
predicted = zeros(N,1);
tookll = input(:,size(input,2));

loglikely = 0;
for i = 1:N
    ll = (input(i,4)^alpha)/(1+k*(input(i,3)/12));
    ss = (input(i,2)^alpha)/(1+k*(input(i,1)/12));
    predicted(i) = 1/(1+exp(p*(ss-ll))); % chance of choosing LL
       if predicted(i)==0
        predicted(i)=.00000001;
    elseif predicted(i)==1
        predicted(i)=.99999999;
   end
    % predicted(i) = 1/(1+exp((10^p)*(ss-ll))); % chance of choosing LL
    likelihood = predicted(i)*tookll(i)+(1-predicted(i))*(1-tookll(i));
    loglikely = loglikely + log(likelihood);
end

output = -loglikely; % negative because we're using fMINcon

return